package game.Elements;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class Elements extends Activity 
{
    /** Called when the activity is first created. */
	private View m_MainView;
	
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        
        m_MainView = new Main(this);
        //View testView = new test(this);
        setContentView(m_MainView);
    }
    
    @Override
    public void onPause() 
    {
        super.onPause();
        // When our activity pauses, we want our view to stop updating its logic.
        // This prevents your application from running in the background, which eats up the battery.
        //((View) m_MainView).setActive(false);
    }     
    
    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
		if((event.getAction() == MotionEvent.ACTION_DOWN)) 
	    {
	    	//Log.d(TAG, "down");
			((Main) m_MainView).SetTouch(event.getX(),event.getY(),1);
	    	return true;
		}
	    else if(event.getAction() == MotionEvent.ACTION_UP)
	    {
	    	//Log.d(TAG, "up");
	    	((Main) m_MainView).SetTouch(event.getX(),event.getY(),2);
	    	return true;
	    }
	    else if(event.getAction() == MotionEvent.ACTION_MOVE)
	    {
	    	//Log.d(TAG, "move");
	    	return true;
	    }
	    else if((event.getAction() == MotionEvent.ACTION_OUTSIDE)) 
	    {
	    	//Log.d(TAG, "up");
	    	//thread.setTouch(event.getX(),event.getY());
	    	return true;	    	
	    }    	
    	
		return true;
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) 
    {
    	/*
    	if (keyCode == KeyEvent.KEYCODE_BACK)
    	{
    		return true;
    	}
    	else if (keyCode == KeyEvent.KEYCODE_SEARCH)
    	{
    		return true;    		
    	}
    	else if (keyCode == KeyEvent.KEYCODE_POWER)
    	{
    		return true;    	
    	}
    	*/
    	
        return super.onKeyDown(keyCode, event);
    }     
}